#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/16 15:16
# @Author: 徐洪英
# @Email: xx@gmail.com
# @File：rie_delete_page.py
from selenium.webdriver.common.by import By
from config.config import HOST
from time import sleep
from pages.base_page import BasePage
class CrmDeleteRiePage(BasePage):
    """类属性"""
    url="http://{}/crm/index.php?m=finance&a=index&t=receivables".format(HOST)

    delete_ys_locator = (By.NAME, "receivables_id[]")  # 定位选择删除的应收
    all_delete_ys_locator = (By.ID, "check_all")  # 定位全部选择删除的应收
    delete_locator = (By.ID, "delete")  # 删除
    alert_add_success_locator = (By.XPATH, "/html/body/div[5]/div[2]")  # 断言添加成功
    alert_delete_success_locator = (By.XPATH, "/html/body/div[5]/div[2]")  # 断言删除成功
    rie_list_locator=(By.CSS_SELECTOR,"body > div.container > div.page-header > ul > li:nth-child(3) > a")#点击应收单


    def choose_delete_rie(self):
        """选择需要删除的应收"""
        self.driver.find_element(*self.delete_ys_locator).click()
    def all_delete_rie(self):
        """全部删除"""
        self.driver.find_element(*self.all_delete_ys_locator).click()

    def clickdelete_rie(self):
        """点击删除按钮"""
        self.driver.find_element(*self.delete_locator).click()
    def accput_delete(self):
        """确认删除弹框"""
        self.driver.switch_to.alert.accept()#弹框确认
    def actual_deleta_stutas(self):
        """断言删除应收款"""
        actual = self.driver.find_element(*self.alert_delete_success_locator).text
        return actual